<include file="../Public/_header.html" />
<style>
.hp_topimg {
	border: 1px solid #E2E2E2;
	display: block;
	float: left;
	line-height: 0;
	margin: 10px 0 10px 10px;
	overflow: hidden;
	position: relative;
	width: 270px;
}

.hp_topimg em {
	bottom: 3px;
	color: #FFFFFF;
	height: 18px;
	left: 5px;
	line-height: 20px;
	position: absolute;
	text-align: right;
	width: 255px;
	z-index: 2;
}

.hp_topimg em a {
	color: #FFFFFF;
}

.hp_topimg span {
	background: none repeat scroll 0 0 #000000;
	bottom: 1px;
	height: 20px;
	left: 1px;
	opacity: 0.5;
	position: absolute;
	width: 268px;
	z-index: 1;
}

.hp_topimg img {
	height: 145px;
	padding: 1px;
	width: 268px;
}
.hp_recommend{
	border: 1px solid #E2E2E2;
	display: block;
	float: left;
	line-height: 0;
	margin: 10px 0 10px 10px;
	overflow: hidden;
	position: relative;
	width: 160px;
}

.hp_recommend em {
	bottom: 3px;
	color: #FFFFFF;
	height: 18px;
	left: 5px;
	line-height: 20px;
	position: absolute;
	text-align: right;
	width: 145px;
	z-index: 2;
}

.hp_recommend em a {
	color: #FFFFFF;
}

.hp_recommend span {
	background: none repeat scroll 0 0 #000000;
	bottom: 1px;
	height: 20px;
	left: 1px;
	opacity: 0.5;
	position: absolute;
	width: 158px;
	z-index: 1;
}

.hp_recommend img {
	height: 160px;
	padding: 1px;
	width: 158px;
}
</style>
<script>
	function fold(index) {
		$('#app_' + index).slideToggle('fast');
	}

	function editHPImg() {
		$("#main_area").html('数据加载中...');
		$.ajax({
			url : "{:U('Admin://Global/hpImgEdit')}",
			type : 'get', //数据发送方式  
			data : {},
			async : false,//同步方式     
			success : function(html) {
				$('#main_area').html(html);
			}
		});
	}
	
	function ajxEditHpImg(img_src, opt_,img_href) {
		$.ajax({
			url : "{:U('Admin://Global/ajxEditHpImg')}",
			type : 'post', //数据发送方式  
			data : {
				img_src : img_src,
				img_href : img_href,
				opt : opt_
			},
			async : false,//同步方式     
			success : function(html) {
				//alert(html);
				txt = eval('(' + html + ')');
				if (txt.status == 1) {
					k_success('操作成功！');
					location.href = "{:U('/Global/hp')}";
				} else {
					k_error('操作失败！');
				}
			}
		});
	}
	function setHpRecommend(shelfid, opt_) {
		$.ajax({
			url : "{:U('Admin://Global/setHpRecommend')}",
			type : 'post', //数据发送方式  
			data : {
				shelfid : shelfid,
				opt : opt_
			},
			async : false,//同步方式     
			success : function(html) {
				//alert(html);
				txt = eval('(' + html + ')');
				if (txt.status == 1) {
					k_success('操作成功！');
					k_page_redirect("{:U('Admin://Global/hp')}");
				} else {
					k_error('操作失败！');
				}
			}
		});
	}
	function setHpHot(sids) {
		$.ajax({
			url : "{:U('Admin://Global/setHpHot')}",
			type : 'post', //数据发送方式  
			data : {
				shelfids : sids
			},
			async : false,//同步方式     
			success : function(html) {
				alert(html);
				txt = eval('(' + html + ')');
				if (txt.status == 1) {
					k_success(txt.msg);
					k_page_redirect("{:U('Admin://Global/hp')}");
				} else {
					k_error(txt.msg);
				}
			}
		});
	}
</script>
<div class="so_main"><span style="float: right; margin-top: 10px;">
<a href="{:U('Admin://Global/hp')}"> <input type="button"
	class="btn_b" value="基本信息" /> </a>
&nbsp;&nbsp;&nbsp;&nbsp; <a href="javascript:void(0)"
	onclick="editHPImg();"> <input type="button" class="btn_b"
	value="编辑图片" /> </a> </span>
<div class="page_tit">首页管理</div>

<div class="form2" id="main_area">
<h3 onclick="fold('2');">今日推荐</h3>
<div id="app_2">
	<div class="hp_recommend">
		<em> 
			<a 	href="javascript:void(0)" title="当修改了商品名称等信息，点击此处刷新推荐数据！"
				onclick="setHpRecommend('{$product['shelf_id']}','set')">刷新</a>
			&nbsp;&nbsp;&nbsp;&nbsp;
			<a 	href="javascript:void(0)" title="删除当前推荐！"
				onclick="setHpRecommend('','del')">删除</a>
		</em> 
		<span></span> 
		<img src="{:getPhotoFromThumb($product['goods_icon'],200,200)}" style="position: relative;">
	</div>
	<dl style="width:100%">
		<dt style="width: 100px;"><strong>设置推荐：</strong></dt>
		<dd><input type="text" value="" id="shelfid">&nbsp;&nbsp;
		<input type="button" value="确定"
			onclick="setHpRecommend($('#shelfid').val(),'set')" class="btn_b">
		&nbsp;&nbsp;录入货架ID，设置今日推荐！推荐只有一个！
		</dd>
		<dt style="width: 100px;"><strong>商品名称：</strong></dt>
		<dd>
			{$product['goods_title']}
		</dd>
		<dt style="width: 100px;"><strong>商品品牌：</strong></dt>
		<dd>
			{$product['partner_title']}
		</dd>
		<dt style="width: 100px;"><strong>买出价格：</strong></dt>
		<dd>
			{:formatMoney($product['shelf_out_price'])}
		</dd>
		<dt style="width: 100px;"><strong>商品简介：</strong></dt>
		<dd>
			{$product['goods_summary']}
		</dd>
	</dl>
</div>
<h3 onclick="fold('3');">热门礼品</h3>
<div id="app_3">
	<dl style="width:100%">
		<dt style="width: 100px;"><strong>设置热门礼品：</strong></dt>
		<dd style="margin-left: 105px;">
		<input type="text" value="{$hotshelfids}" id="shelfids" style="width:300px;">&nbsp;&nbsp;
		<input type="button" value="确定"
			onclick="setHpHot($('#shelfids').val())" class="btn_b">
		&nbsp;&nbsp;录入货架ID以','分割（最少8个，按购买次数排序）。如果为空则所有商品按购买次数排序。
		</dd>
	</dl>
	<div>
		<volist id="hvo" name="hotProduct">
		<div class="hp_recommend">
			<em> 
				{$hvo['goods_title']}
			</em> 
			<span></span> 
			<img src="{:getPhotoFromThumb($hvo['goods_icon'],200,200)}" style="position: relative;">
		</div>
		</volist>
	</div>
</div>
<div class="clear"></div>
	<h3 onclick="fold('1');">首页图片</h3>
	<div id="app_1">
		<div>
			<volist id="vo" name="hpimgs">
				<div class="hp_topimg">
					<em>
						<a href="javascript:void(0);" callback="ajxEditHpImg('{$vo['img']}','href',$('#img_href').val());"
						 	onclick=" ui.confirm(this,'图片链接：<input type=\\'text\\' style=\\'width:280px;height: 20px; font-size: 12px;line-height: 20px;\\' id=\\'img_href\\' value=\\'{$vo['href']}\\' />'); ">链接</a>
						&nbsp;&nbsp;&nbsp;&nbsp;
						<a href="javascript:void(0)" onclick="ajxEditHpImg('{$vo['img']}','top')">置顶</a>
						&nbsp;&nbsp;&nbsp;&nbsp;
						<a href="javascript:void(0)" onclick="ajxEditHpImg('{$vo['img']}','del')">删除</a>
					</em> 
					<span></span> 
					<a href="{$vo['href']}" target="_blank">
					<img src="{:getPhotoFromThumb($vo['img'],270,145)}" style="position: relative;">
					</a>
				</div>
			</volist>
		</div>
		<div class="clear"></div>
	</div>

</div>
</div>

<include file="../Public/_footer.html" />